home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / suncom.zip / SUNINC.INC < prev    next >
Text File  |  1990-02-24  |  17KB  |  538 lines

  1.  
  2. (************************************************************************)
  3.  
  4. PROCEDURE Line(LineChr,
  5.                LineLength,
  6.                Color       : Integer);
  7. VAR Counter : Integer;
  8. begin
  9.      textcolor(Color);
  10.      for Counter := 1 to LineLength do
  11.          begin
  12.               write(chr(LineChr));
  13.          end;
  14. end;
  15.  
  16. (****************************************************************************)
  17.  
  18. FUNCTION ReadPause  : Boolean;
  19. VAR x,y      : Integer;
  20.     Question : Char;
  21. LABEL Beginning;
  22. begin
  23.      while keypressed do
  24.           begin
  25.                X := whereX;
  26.                Y := whereY;
  27.                SETSCREEN(lightred+blink,black,0,65,1,79,1);
  28.                OFFCURSOR;
  29.                write('FILE PAUSED.');
  30.                Beginning:
  31.                Question := ReadKey;
  32.                if Question = #27
  33.                   then begin
  34.                             READPAUSE := TRUE;
  35.                             exit;
  36.                        end;
  37.                if Question <> #13 then goto Beginning;
  38.                ONCURSOR;
  39.                SETSCREEN(white,black,0,65,1,79,1);
  40.                SETSCREEN(white,black,1,1,2,79,25);
  41.                gotoxy(X,Y);
  42.                READPAUSE := FALSE;
  43.           end;
  44. end;
  45.  
  46. (*****************************************************************************)
  47.  
  48. PROCEDURE LIST_TO_PRINTER(FileName : String);
  49.  
  50. CONST
  51.   PageWidth = 80;
  52.   PrintLength = 55;
  53.   PathLength  = 65;
  54.   FormFeed = #12;
  55.   VerticalTabLength = 3;
  56.  
  57. TYPE
  58.   WorkString  = String[126];
  59.  
  60. VAR
  61.   CurRow      : Integer;
  62.   MainFile    : Text;
  63.  
  64. {---------------------------------------------------------------------------}
  65.  
  66. PROCEDURE VerticalTab;
  67. VAR i: integer;
  68. begin
  69.     for i := 1 to VerticalTabLength do Writeln(LST);
  70. end {vertical tab};
  71.  
  72. {---------------------------------------------------------------------------}
  73.  
  74. PROCEDURE ProcessLine(PrintStr: WorkString);
  75. begin
  76.     CurRow := Succ(CurRow);
  77.     if Length(PrintStr) > PageWidth then Inc(CurRow);
  78.     if CurRow > PrintLength then
  79.     begin
  80.       Write(LST,FormFeed);
  81.       VerticalTab;
  82.       CurRow := 1;
  83.     end;
  84.     Writeln(LST,PrintStr);
  85. end {Process line};
  86.  
  87. {---------------------------------------------------------------------------}
  88.  
  89. PROCEDURE ProcessFile(FileName : string);
  90.   { This procedure displays the contents of the File to the Printer }
  91.  
  92. VAR
  93.     LineBuffer: WorkString;
  94.  
  95. begin  {Process File}
  96.     VerticalTab;
  97.     while not EOF(mainfile) do
  98.     begin
  99.       Readln(MainFile,LineBuffer);
  100.       ProcessLine(LineBuffer);
  101.       if READPAUSE = TRUE then Exit;
  102.     end;
  103.     Close(MainFile);
  104.     Write(LST,FormFeed); { move the printer to the beginning of the next }
  105.                          { page }
  106. end {Process File};
  107.  
  108. {---------------------------------------------------------------------------}
  109. begin {List_To_Printer}
  110.   CurRow := 0;
  111.   assign(MainFile,FileName);
  112.   reset(MainFile);
  113.   ProcessFile(FileName);
  114. end; {List_To_Printer}
  115.  
  116. (****************************************************************************)
  117.  
  118. PROCEDURE Read_File(VAR Config : ConfigRec);
  119. VAR Source          : String;
  120.     Chars,
  121.     Mode,
  122.     Question        : Char;
  123.     DataFile        : File of Char;
  124.     Modem,
  125.     dbool           : Boolean;
  126. begin
  127.      WINDOWIN(white,blue,4,10,10,70,12,CursorCol,CursorRow,WindowPtr);
  128.      textcolor(yellow);
  129.      write(' Read Filename: ');
  130.      textcolor(white);
  131.      readln(Source);
  132.      if length(Source) = 0 then
  133.         begin
  134.              WINDOWOUT(CursorCol,CursorRow,WindowPtr);
  135.              exit;
  136.         end;
  137.      textcolor(yellow);
  138.      SETSCREEN(black,black,0,10,10,70,12);
  139.      MAKEWINDOW(white,blue,4,0,25,10,55,16);
  140.      OFFCURSOR;
  141.      textcolor(yellow);
  142.      writeln('    Select Display Device');
  143.      LINE(196,29,white);
  144.      textcolor(yellow);
  145.      writeln('         S - Screen ');
  146.      writeln('         P - Printer');
  147.      write('         M - Modem  ');
  148.      Mode := ReadKey;
  149.      Mode := UpCase(Mode);
  150.      ONCURSOR;
  151.      if not(Mode in ['M','P'])
  152.         then Mode := 'S';
  153.      if Mode = 'M'
  154.         then Modem := True
  155.         else Modem := False;
  156.      SETSCREEN(white,black,0,1,1,80,25);
  157.      SETSCREEN(white,black,0,1,1,80,1);
  158.      write('Printing File: ');
  159.      textcolor(yellow);
  160.      write(Source);
  161.      textcolor(white);
  162.      write('     Mode: ');
  163.      textcolor(yellow);
  164.      case Mode of
  165.          'M' : write('Modem  ');
  166.          'S' : write('Screen ');
  167.          'P' : write('Printer');
  168.      end; {case}
  169.      SETSCREEN(white,black,0,1,2,80,25);
  170.      write('Press ENTER when Ready or ESC to Exit.');
  171.      Question := readkey;
  172.      if Question = #27 then
  173.         begin
  174.              WINDOWOUT(CursorCol,CursorRow,WindowPtr);
  175.              exit;
  176.         end;
  177.      clrscr;
  178.      assign(DataFile,Source);
  179.      {$I-}
  180.      reset(DataFile);
  181.      {$I+}
  182.      if IOResult <> 0 then
  183.         begin
  184.              MAKEWINDOW(yellow,red,4,0,31,11,49,13);
  185.              textcolor(white+blink);
  186.              OFFCURSOR;
  187.              write(' File Not Found!',^G);
  188.              repeat until KeyPressed;
  189.              ONCURSOR;
  190.              WINDOWOUT(CursorCol,CursorRow,WindowPtr);
  191.              exit;
  192.         end;
  193.      if Mode = 'P'
  194.         then begin
  195.                   LIST_TO_PRINTER(Source);
  196.                   SETSCREEN(red,white,0,1,1,80,1);
  197.                   write('                   Printing Completed. Press Any Key.');
  198.                   Question := readkey;
  199.                   WINDOWOUT(CursorCol,CursorRow,WindowPtr);
  200.                   exit;
  201.              end;
  202.      while not eof(DataFile) do
  203.          begin
  204.               read(DataFile,Chars);
  205.               ANSIDRIVER(Chars);
  206.               if Modem = True
  207.                  then begin
  208.                            Async_Send(Chars);
  209.                            delay(10);
  210.                       end;
  211.               if READPAUSE = True
  212.                  then begin
  213.                            WINDOWOUT(CursorCol,CursorRow,WindowPtr);
  214.                            exit;
  215.                       end;
  216.          end;
  217.      close(DataFile);
  218.      SETSCREEN(red,white,0,1,1,80,1);
  219.      write('                   Printing Completed. Press Any Key.');
  220.      Question := readkey;
  221.      WINDOWOUT(CursorCol,CursorRow,WindowPtr);
  222. end;
  223.  
  224. (****************************************************************************)
  225.  
  226. PROCEDURE ReturnBeep(VAR Config : ConfigRec);
  227. VAR Lcv : Byte;
  228. begin
  229.     Lcv := 0;
  230.     if Config.MuteMode = Off
  231.        then
  232.            repeat
  233.               Sound(500);
  234.               delay(50);
  235.               Sound(1000);
  236.               delay(50);
  237.               Lcv := Lcv + 1;
  238.            until KeyPressed or (Lcv = 30);
  239.     nosound;
  240. end;
  241.  
  242. (************************************************************************)
  243. (*         Hex_To_Dec --- Convert hex string to decimal number          *)
  244. (************************************************************************)
  245.  
  246. FUNCTION Hex_To_Dec( S : AnyStr; Default : Integer ) : Integer;
  247.  
  248. (************************************************************************)
  249. (*                                                                      *)
  250. (*     Function:   Hex_To_Dec                                           *)
  251. (*                                                                      *)
  252. (*     Purpose:    Convert hex string to decimal number                 *)
  253. (*                                                                      *)
  254. (*     Calling Sequence:                                                *)
  255. (*                                                                      *)
  256. (*        Integ := Hex_To_Dec( S: AnyStr; Default: Integer ) : Integer; *)
  257. (*                                                                      *)
  258. (*           S       --- the hex string                                 *)
  259. (*           Default --- value to return if S not hex string            *)
  260. (*           Integ   --- corresponding decimal Integer (0 if bad)       *)
  261. (*                                                                      *)
  262. (**********************